<?php 
	session_start();
	
	if(!isset($_SESSION['User_Session'])) {
		header("Location: login.php");
	}
	session_write_close();
?>
<html>
<head>
	<title>Textblast</title>
	<style type="text/css" >
		body {
			margin: 0px;
			padding: 0px;
			font-size: 10pt;
			font-family: sans-serif,tahoma, verdana, 'lucida grande',arial;
			
			background: #EAEAEA;
		}
		#header {
			background-color: White;
			display: block;
			position: fixed;
			width: 100%;
			padding: 5px;
			color: white;
			border-color: lightgray;
			border-width: 1;
			border-style: solid;
		}
		#body {
			height: 100%;
		}
		#leftPanel {
			/*background-color: white;*/
			position: fixed;
			margin-top: 28px;
			padding: 0 10px;
			height: auto;
			width: 180px;
			/*border-color: gray;
			border-width: 1;
			border-style: solid;*/
		}
		#contentPanel {
			display: inline-block;
			margin-top: 15px;
			margin-left: 180px;
			height: 80%;
			/*width: 80%;*/
			/*border-color: gray;
			border-width: 1;
			border-style: solid;*/
		}
		#mainContent {
			/*background-color: Azure;*/
			margin: 20px;
			padding: 20px;
			max-width: 1000px;
			
		}
		#logo {
			background-color: white;
			display: block;
			height: 80px;
			border-left-color: lightgray;
			border-left-width: 1;
			border-left-style: solid;
			border-right-color: lightgray;
			border-right-width: 1;
			border-right-style: solid;
			border-top-color: white;
			border-top-width: 1;
			border-top-style: solid;	
		}
		.menu {
			display: block;
			padding-left: 10px;
			padding-top: 10px;
			padding-bottom: 10px;
			margin-right: 10px;
			margin-left: 10px;
			
			border-bottom-color: lightgray;
			border-bottom-width: 1;
			border-bottom-style: solid;	

		}
		.menu a {
			color: black;
			text-decoration:none;
			font-weight: bold;
		}
		.word-wrap {
			white-space: pre-wrap;      /* CSS3 */   
			white-space: -moz-pre-wrap; /* Firefox */    
			white-space: -pre-wrap;     /* Opera <7 */   
			white-space: -o-pre-wrap;   /* Opera 7 */    
			word-wrap: break-word;      /* IE */
		}
		.menu:hover, .menu a:hover {
			background-color: LightBlue;
			color: gray;
		}
		.menuPanel {
			background: WhiteSmoke;
			border-color: lightgray;
			border-width: 1;
			border-style: solid;
			/*-moz-border-radius-bottomright: 25px 50px;
			border-bottom-right-radius: 25px 50px;
			-moz-border-radius-bottomleft: 25px 50px;
			border-bottom-left-radius: 25px 50px;*/
		}
	</style>
	<link rel="stylesheet" type="text/css" href="css/textblast.css"></link>
	<link rel="stylesheet" type="text/css" href="plugins/flexigrid/css/flexigrid.css"></link>
	<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
	<script type="text/javascript" src="js/textblast.js"></script>
	<script type="text/javascript" src="plugins/flexigrid/js/flexigrid.js"></script>
	<script type="text/javascript">
	var loadModule = function(mod) {
		$.ajax({
			url: [mod, '1', '/index.php'].join(''),
			success: function(response) {
				$('#contentPanel').html(response);
			}
		});
	};

	$(document).ready(function() {
		var pathname = window.location.pathname;

		if(/^\/?textblast\//.test(pathname)) {
			var mod = /textblast\/[a-zA-Z0-9]+$/.exec(pathname);

			if(mod) {
				mod = mod[0].split('/')[1];	
			} else {
				mod = 'messages';
			}

			loadModule(mod);
		} else {
			// main domain here
		}

		var $lmenu = $('.lmenu');

		$lmenu.click(function(e) {
			var parent = this.parentNode,
				// if href is not existing, let it fire an error to notify the dev
				val = parent.attributes['href'].nodeValue;

			val = /[a-zA-Z]+[a-zA-Z0-9]+/.exec(val);

			if(val) {
				val = val[0];
			}

			if(window.history.pushState) {
				//var arr = val.split('#');
				e.preventDefault();	

				window.document.title = val + ' | Textblast.com.ph';

				var stateObj = { html: val };
				/*var wa = val;
				if(i > 0) {
					wa = '../' + wa;
				}
				i++;*/

				window.history.pushState(stateObj, val, val);
				
			} else {
				//for ie
			}

			loadModule(val);
		});

		if(!window.history.pushState) {
			window.attachEvent("onhashchange", function() {
				//alert(window.location.hash);
				window.document.title = '[T] ' + window.location.hash;
			});
		}
	});

	</script>
</head>
<body>

<div>
	<!-- <table id="flex"></table> -->
	<div id='header'><span>Textblast.com.ph</span></div>
	<div id='body'>
		<div id='leftPanel'>
			<div id='logo'></div>
			<div class='menuPanel'>
				<!-- <div class='menu'><a href='Home'><span class='lmenu'>Home</span></a></div> -->
				<div class='menu'><a href='Messages'><span class='lmenu'>Messages</span></a></div>
				<div class='menu'><a href='Contacts'><span class='lmenu'>Contacts</span></a></div>
				<!-- <div class='menu'><a href='Organizations'><span class='lmenu'>Organizations</span></a></div> -->
				<div class='menu'><a href='Members'><span class='lmenu'>Members</span></a></div>
				<div class='menu'><a href='Settings'><span class='lmenu'>Settings</span></a></div>
				<div class='menu'><a href='logout.php'><span>Log out</span></a></div>
			</div>
		</div>
		<div id='contentPanel'>
						
		</div>
	<div id='footer'></div>
</div>
</body>
</html>